home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / swapqpu.zip / SWAPTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1992-03-14  |  3KB  |  56 lines

  1. Program SwapTest;      (* By Kevin A. Kwast *)
  2. {$M 8192,0,0}
  3. (**********************************************************************)
  4. (** This program illustrates a DOS shell spawned from a Pascal       **)
  5. (** program.  If you have Turbo Debugger or something similar, you   **)
  6. (** can examine what is left in memory and notice that the constant  **)
  7. (** strings and the Str variable (in data) are NOT in memory.  The   **)
  8. (** literal strings in the program area WILL be in memory however.   **)
  9. (** This is because strings quoted in the code will be placed in the **)
  10. (** code segment.  The $M compiler directive specifies a 8192 byte   **)
  11. (** stack and no heap.  Otherwise, the stack would be at the default **)
  12. (** 16K size, with a heap that will fill all available memory.  That **)
  13. (** will mean that the program memory block to be swapped will be a  **)
  14. (** very large block (all available memory).  Using the $M compiler  **)
  15. (** directive allows you to change these default memory usages and   **)
  16. (** make more efficient use of memory.  If you don't use the heap,   **)
  17. (** be sure to set it to 0 so that no heap will be allocated.  Just  **)
  18. (** for grins, compile this same program using the standard Exec     **)
  19. (** procedure and notice the differences!               --Kevin      **)
  20. (**********************************************************************)
  21.  
  22. { Notice that SwapUnit always comes last on the Uses line! }
  23. Uses Dos, SwapUnit;
  24. Const
  25.      AnyArray = 'This is a constant string.';
  26.      AnotherArray = 'This is another constant string.';
  27.  
  28.      FinalMessage = 'Thank you for trying SWAPUNIT.';
  29.  
  30. Var
  31.    Result: Word;
  32.  
  33.    Str: String;
  34.  
  35. Begin
  36.      WriteLn('This is the swap test (using SwapUnit TPU).');
  37.      WriteLn('EMS 4.0 Test Result: ',CheckEMS);
  38.      WriteLn('XMS Test Result: ',CheckXMS);
  39.  
  40.      WriteLn('Going to the shell... Type EXIT to return..');
  41.  
  42.      Str:=GetEnv('COMSPEC');
  43. { For those without the GetEnv function, just use a declaration like: }
  44. {    Str:='C:\COMMAND.COM'; }
  45.      Result:=SwapExec(Str,'','SWAP.FIL',SwapToAny);
  46.  
  47. { SwapExec is called to execute COMMAND.COM with no command line.  This }
  48. { begins a DOS shell.  If swapping to disk is necessary, the swap file  }
  49. { will be called SWAP.FIL; the SwapToAny parameter specifies that all 3 }
  50. { forms of swapping should be tried.  XMS, then EMS, and then Disk.     }
  51.  
  52.      WriteLn('Returned from the swap.. Results:  High byte = ',Hi(Result),' Low byte = ',Lo(Result));
  53.      WriteLn;
  54.      WriteLn(FinalMessage);
  55.      WriteLn;
  56. End.